| Author | Manuela Ruiz (mruiz@lcc.uma.es) |
Class that establishes a lexicographyc ordering of the points, taking into account a tolerance threshold given by Constants::EPSILON
| other_point | another OrderedPoint |
| returns | true if this point is lesser than other_point |
# File lib/geometry.rb, line 29
29: def < (other_point)
30: result = false
31: dif_x = @point.x - other_point.x
32: abs_x = dif_x.abs
33: if (dif_x < 0) && (abs_x > Constants::EPSILON)
34: result = true
35: elsif abs_x < Constants::EPSILON
36: dif_y = @point.y - other_point.y
37: abs_y = dif_y.abs
38: if (dif_y < 0) && (abs_y > Constants::EPSILON)
39: result = true
40: end
41: end
42: return result
43: end
| other_point | another OrderedPoint |
| returns | true if this point is lesser or equal than other_point |
# File lib/geometry.rb, line 72
72: def <= (other_point)
73: less = (self < other_point)
74: equal = (self == other_point)
75: return (less || equal)
76: end
| other_point | another OrderedPoint |
| returns | true if this point is equal to other_point |
# File lib/geometry.rb, line 48
48: def == (other_point)
49: result = false
50: if other_point.kind_of? OrderedPoint
51: dif_x = @point.x - other_point.x
52: abs_x = dif_x.abs
53: dif_y = @point.y - other_point.y
54: abs_y = dif_y.abs
55: if ((abs_x < Constants::EPSILON) && (abs_y < Constants::EPSILON))
56: result = true
57: end
58: end
59: return result
60: end
| other_point | another OrderedPoint |
| returns | true if this point is bigger than other_point |
# File lib/geometry.rb, line 65
65: def > (other_point)
66: return (other_point < self)
67: end
| other_point | another OrderedPoint |
| returns | true if this point is bigger or equal than other_point |
# File lib/geometry.rb, line 81
81: def >= (other_point)
82: great = (other_point < self)
83: equal = (self== other_point)
84: return (great || equal)
85: end
| returns | an OrderedPoint object identical to this |
# File lib/geometry.rb, line 98
98: def clone()
99: return OrderedPoint.new(@point.clone)
100: end
| other_point | another OrderedPoint |
| returns | true if this point is equal to other_point |
# File lib/geometry.rb, line 105
105: def eql?(other_point)
106: result = false
107: if other_point.kind_of? OrderedPoint
108: dif_x = @point.x - other_point.x
109: abs_x = dif_x.abs
110: dif_y = @point.y - other_point.y
111: abs_y = dif_y.abs
112: if ((abs_x < Constants::EPSILON) && (abs_y < Constants::EPSILON))
113: result = true
114: end
115: end
116: return result
117: end
| returns | the hash code of this point |
# File lib/geometry.rb, line 120
120: def hash
121: return [self.x.hash, self.y.hash].hash
122: end
| returns | the internal Point |
# File lib/geometry.rb, line 146
146: def point()
147: if Shade.using_sketchup
148: return Geom::Point3d.new(@point.x, @point.y, 0)
149: else
150: return @point
151: end
152: end
| t | 2x3 transformation matrix |
Transform the point according to t
# File lib/geometry.rb, line 127
127: def transform(t)
128: #Extract the coefficients of the transformation matrix
129: ax = t[0]
130: bx = t[1]
131: cx = t[2]
132: ay = t[3]
133: by = t[4]
134: cy = t[5]
135: new_shape = self.clone
136:
137: #Transform the point
138: new_x = @point.x * ax + @point.y * bx + cx
139: new_y = @point.x * ay + @point.y * by + cy
140:
141: @point.x = new_x
142: @point.y = new_y
143: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.